#import "TestIosStatusBarPlugin.h"


@interface TestIosStatusBarPlugin ()
@property(strong, nonatomic) FlutterMethodChannel* _channel;// 发送消息的channel
 
@end

static TestIosStatusBarPlugin* _instance;// 单例声明

@implementation TestIosStatusBarPlugin

+ (id) shareInstance {// 使用单例模式，将plugin唯一，
    static dispatch_once_t onceToken;
    _dispatch_once(&onceToken, ^{
        if (_instance == nil){
            _instance = [[TestIosStatusBarPlugin alloc] init];
        }
    });
    return _instance;
}

+ (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar>*)registrar {
    FlutterMethodChannel* _channel = [FlutterMethodChannel
      methodChannelWithName:@"test_ios_status_bar"
            binaryMessenger:[registrar messenger]];
  TestIosStatusBarPlugin* instance = [TestIosStatusBarPlugin shareInstance];// 使用单例获取
    [instance set_channel:_channel];
  [registrar addMethodCallDelegate:instance channel:_channel];
}


+ (FlutterMethodChannel*)getChannel {
    return  [[TestIosStatusBarPlugin shareInstance] _channel];// 使用单例获取
}

- (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result {
  if ([@"getPlatformVersion" isEqualToString:call.method]) {
    result([@"iOS " stringByAppendingString:[[UIDevice currentDevice] systemVersion]]);
  } else {
    result(FlutterMethodNotImplemented);
  }
}

@end
